﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using KCL.Code;
using KCL.Code.Business;

namespace KCL.Components
{
    public partial class uscColor : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            btnAddColor.Enabled = dgvColor.Columns[2].Visible = (bool)Session[SessionManager.canCreate];
            dgvColor.Columns[1].Visible = (bool)Session[SessionManager.canModify];
        }

        protected void btnAddColor_Click(object sender, EventArgs e)
        {
            if (txtColorName.Text.Trim().Length > 0)
            {
                Color c = new Color();
                c.name = txtColorName.Text.Trim();
                c.isActive = true;
                ColorServices.Insert(c);
                dgvColor.DataBind();
                dgvColor.PageIndex = dgvColor.PageCount - 1;
            }
        }
    }
}